package com.zlf.mapper;

import com.zlf.po.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {
    @Select("select * from user where userId=#{userId}")
    public User getUserByIdByPass(User user);

    @Select("select * from user where userId=#{userId}")
    public User getUserById(String userId);

    @Insert("insert into user values(#{userId},#{password},#{userName},#{userSex},#{userImg},1)")
    public int saveUser(User user);

    @Update("update  user set password=#{newPassword} where userId=#{userId}")
    public int updateUserPass(String newPassword,String userId);

    @Update("update  user set userName=#{newNickname} where userId=#{userId}")
    public int updateNickname(String userId,String newNickname);

    @Update("update  user set userImg=#{avatarBase64} where userId=#{userId}")
    public int uploadAvatarBase64(String userId,String avatarBase64);

    @Select("select password from user where userId=#{userId}")
    public String getHashedPasswordById(String userId);

}
